# import os
# ret=os.system('tasklist |find "py.exe"')
# print(ret)
# ret=1
import psutil
import os
FILE="D:\wangb_program\atm_face_new\main.py"
def get_proc_by_name(pname):
    """ get process by name

    return the first process if there are more than one
    """
    for proc in psutil.process_iter():
        try:
            if proc.name().lower() == pname.lower():

                return True  # return if found one
        except psutil.AccessDenied:
            pass
        except psutil.NoSuchProcess:
            pass
    return False

#杀死进程。
def kill_proc_by_name(pname):
    """ get process by name

    return the first process if there are more than one
    """
    for proc in psutil.process_iter():
        try:
            if proc.name().lower() == pname.lower():
                proc.kill()
                return True
        except psutil.AccessDenied:
            pass
        except psutil.NoSuchProcess:
            pass
    return False

kill_proc_by_name('py.exe')
os.system('D:\\wangb_program\\atm_face_new\\main.py')